package gui;

import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyFrame extends JFrame{
	private static final long serialVersionUID = 1L;

	public static void main(String[] args) {
		MyFrame mf = new MyFrame();
		JButton btn1 = new JButton("button1");
		JButton btn2 = new JButton("button2");
		JButton btn3 = new JButton("button3");
		JButton btn4 = new JButton("button4");
		JPanel panel = new JPanel();
		
		//给button设置一个监听回调函数，当点击button时执行函数
		btn1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("btn1 clicked...");
			}
		});
		
		
		mf.setSize(400, 300);				//设置窗体大小
//		mf.setLocation(new Point(200,300));
		mf.setLocationRelativeTo(null);		//设置窗体相对关系，当null时直接相对系统窗体居中
		mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		//窗体关闭的动作
		
		mf.setVisible(true);	//设置窗体可见
		mf.setResizable(false);		//设置窗体不可改变大小
		
		mf.setLayout(new BorderLayout());	//设置窗体布局方式为borderlayout
		mf.add(btn1,BorderLayout.NORTH);	//窗体添加组件
		mf.add(btn2,BorderLayout.SOUTH);
		
		panel.setLayout(new BorderLayout());
		panel.add(btn3,BorderLayout.WEST);
		panel.add(btn4,BorderLayout.EAST);
		mf.add(panel);
		
		
	}
}
